| Conditions | 1 |
| Paths | 1 |
| Total Lines | 111 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 11 | describe("Testing Module", function() { |
||
| 12 | |||
| 13 | describe("Testing so function returns correct type", function() { |
||
| 14 | it("catchPhrase should return string", function() { |
||
| 15 | let module = new Module(); |
||
| 16 | |||
| 17 | assert("string", typeof(module.getCatchPrase())); |
||
| 18 | }); |
||
| 19 | |||
| 20 | it("joke should return string", function() { |
||
| 21 | let module = new Module(); |
||
| 22 | |||
| 23 | assert("string", typeof(module.getJoke())); |
||
| 24 | }); |
||
| 25 | |||
| 26 | it("quote should return string", function() { |
||
| 27 | let module = new Module(); |
||
| 28 | |||
| 29 | assert("string", typeof(module.getQuote())); |
||
| 30 | }); |
||
| 31 | |||
| 32 | it("asci should return string", function() { |
||
| 33 | let module = new Module(); |
||
| 34 | |||
| 35 | assert("string", typeof(module.getAsci())); |
||
| 36 | }); |
||
| 37 | }); |
||
| 38 | |||
| 39 | describe("Testing so getCheckCommand returns correct type", function() { |
||
| 40 | it("/catchPhrase should return string", function() { |
||
| 41 | let module = new Module(); |
||
| 42 | |||
| 43 | assert("string", typeof(module.getCheckCommand('/catchPhrase'))); |
||
| 44 | }); |
||
| 45 | |||
| 46 | it("/joke should return string", function() { |
||
| 47 | let module = new Module(); |
||
| 48 | |||
| 49 | assert("string", typeof(module.getCheckCommand('/joke'))); |
||
| 50 | }); |
||
| 51 | |||
| 52 | it("/asci should return string", function() { |
||
| 53 | let module = new Module(); |
||
| 54 | |||
| 55 | assert("string", typeof(module.getCheckCommand('/asci'))); |
||
| 56 | }); |
||
| 57 | |||
| 58 | it("/quote should return string", function() { |
||
| 59 | let module = new Module(); |
||
| 60 | |||
| 61 | assert("string", typeof(module.getCheckCommand('/quote'))); |
||
| 62 | }); |
||
| 63 | }); |
||
| 64 | |||
| 65 | describe("Testing type of object in Module", function() { |
||
| 66 | it("checking 'catchPhrase'", function() { |
||
| 67 | let module = new Module(); |
||
| 68 | |||
| 69 | assert("object", typeof(module.catchPhrase)); |
||
| 70 | }); |
||
| 71 | |||
| 72 | it("checking 'asci'", function() { |
||
| 73 | let module = new Module(); |
||
| 74 | |||
| 75 | assert("object", typeof(module.asci)); |
||
| 76 | }); |
||
| 77 | |||
| 78 | it("checking 'joke'", function() { |
||
| 79 | let module = new Module(); |
||
| 80 | |||
| 81 | assert("object", typeof(module.joke)); |
||
| 82 | }); |
||
| 83 | |||
| 84 | it("checking 'quote'", function() { |
||
| 85 | let module = new Module(); |
||
| 86 | |||
| 87 | assert("object", typeof(module.quote)); |
||
| 88 | }); |
||
| 89 | |||
| 90 | }); |
||
| 91 | |||
| 92 | describe("Testing size", function() { |
||
| 93 | it("checking 'catchPhrase'", function() { |
||
| 94 | let module = new Module(); |
||
| 95 | |||
| 96 | assert.equal(6, module.getCatchPraseSize()); |
||
| 97 | }); |
||
| 98 | |||
| 99 | it("checking 'joke'", function() { |
||
| 100 | let module = new Module(); |
||
| 101 | |||
| 102 | assert.equal(2, module.getJokeSize()); |
||
| 103 | }); |
||
| 104 | |||
| 105 | it("checking 'quote'", function() { |
||
| 106 | let module = new Module(); |
||
| 107 | |||
| 108 | assert.equal(7, module.getQuoteSize()); |
||
| 109 | }); |
||
| 110 | |||
| 111 | it("checking 'asci'", function() { |
||
| 112 | let module = new Module(); |
||
| 113 | |||
| 114 | assert.equal(9, module.getAsciSize()); |
||
| 115 | }); |
||
| 116 | |||
| 117 | |||
| 118 | }); |
||
| 119 | |||
| 120 | |||
| 121 | }); |
||
| 122 |